home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / c / ExtrasLib.lha / ExtrasLib / Source / StrIStr.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-30  |  1.0 KB  |  52 lines

  1. #include <exec/types.h>
  2. #include <string.h>
  3.  
  4. #include <clib/extras/string_protos.h>
  5.  
  6. /****** extras.lib/StrIStr ******************************************
  7. *
  8. *   NAME
  9. *       StrIStr -- search for a string in another string, case 
  10. *                  insenseitive.
  11. *
  12. *   SYNOPSIS
  13. *       StrIStr(InStr,SearchStr)
  14. *
  15. *       STRPTR StrIStr(STRPTR InStr,STRPTR SearchStr);
  16. *
  17. *   FUNCTION
  18. *       Seach for a string inside another, case insensitive.
  19. *
  20. *   INPUTS
  21. *       InStr - the string to search in.
  22. *       SearchStr - the string to search for.
  23. *
  24. *   RESULT
  25. *       returns a pointer in InStr that matches SearchStr, or NULL
  26. *       if no match was found.
  27. *
  28. ******************************************************************************
  29. *
  30. */
  31.  
  32.  
  33.  
  34. STRPTR StrIStr(STRPTR InStr,STRPTR SearchStr)
  35. {
  36.   LONG l,l2,t=0;
  37.   
  38.   if(InStr && SearchStr)
  39.   {
  40.     l2=strlen(SearchStr);
  41.     l=strlen(InStr)-l2;
  42.     
  43.     while(t<=l)
  44.     {
  45.       if(strnicmp(&InStr[t],SearchStr,l2)==0)
  46.         return(&InStr[t]);
  47.       t++;
  48.     }
  49.   }
  50.   return(0);
  51. }
  52.